# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.FusionTables.V2.Api.Table do
  @moduledoc """
  API calls for all endpoints tagged `Table`.
  """

  alias GoogleApi.FusionTables.V2.Connection
  alias GoogleApi.Gax.{Request, Response}

  @library_version Mix.Project.config() |> Keyword.get(:version, "")

  @doc """
  Copies a table.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `table_id` (*type:* `String.t`) - ID of the table that is being copied.
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:copyPresentation` (*type:* `boolean()`) - Whether to also copy tabs, styles, and templates. Default is false.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.FusionTables.V2.Model.Table{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_copy(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
          {:ok, GoogleApi.FusionTables.V2.Model.Table.t()} | {:error, Tesla.Env.t()}
  def fusiontables_table_copy(connection, table_id, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :copyPresentation => :query
    }

    request =
      Request.new()
      |> Request.method(:post)
      |> Request.url("/fusiontables/v2/tables/{tableId}/copy", %{
        "tableId" => URI.encode(table_id, &URI.char_unreserved?/1)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.FusionTables.V2.Model.Table{}])
  end

  @doc """
  Deletes a table.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `table_id` (*type:* `String.t`) - ID of the table to be deleted.
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_delete(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
          {:ok, nil} | {:error, Tesla.Env.t()}
  def fusiontables_table_delete(connection, table_id, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query
    }

    request =
      Request.new()
      |> Request.method(:delete)
      |> Request.url("/fusiontables/v2/tables/{tableId}", %{
        "tableId" => URI.encode(table_id, &URI.char_unreserved?/1)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [decode: false])
  end

  @doc """
  Retrieves a specific table by its ID.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `table_id` (*type:* `String.t`) - Identifier for the table being requested.
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.FusionTables.V2.Model.Table{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
          {:ok, GoogleApi.FusionTables.V2.Model.Table.t()} | {:error, Tesla.Env.t()}
  def fusiontables_table_get(connection, table_id, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/fusiontables/v2/tables/{tableId}", %{
        "tableId" => URI.encode(table_id, &URI.char_unreserved?/1)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.FusionTables.V2.Model.Table{}])
  end

  @doc """
  Imports more rows into a table.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `table_id` (*type:* `String.t`) - The table into which new rows are being imported.
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:delimiter` (*type:* `String.t`) - The delimiter used to separate cell values. This can only consist of a single character. Default is ,.
      *   `:encoding` (*type:* `String.t`) - The encoding of the content. Default is UTF-8. Use auto-detect if you are unsure of the encoding.
      *   `:endLine` (*type:* `integer()`) - The index of the line up to which data will be imported. Default is to import the entire file. If endLine is negative, it is an offset from the end of the file; the imported content will exclude the last endLine lines.
      *   `:isStrict` (*type:* `boolean()`) - Whether the imported CSV must have the same number of values for each row. If false, rows with fewer values will be padded with empty values. Default is true.
      *   `:startLine` (*type:* `integer()`) - The index of the first line from which to start importing, inclusive. Default is 0.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.FusionTables.V2.Model.Import{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_import_rows(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
          {:ok, GoogleApi.FusionTables.V2.Model.Import.t()} | {:error, Tesla.Env.t()}
  def fusiontables_table_import_rows(connection, table_id, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :delimiter => :query,
      :encoding => :query,
      :endLine => :query,
      :isStrict => :query,
      :startLine => :query
    }

    request =
      Request.new()
      |> Request.method(:post)
      |> Request.url("/fusiontables/v2/tables/{tableId}/import", %{
        "tableId" => URI.encode(table_id, &URI.char_unreserved?/1)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.FusionTables.V2.Model.Import{}])
  end

  @doc """
  Imports more rows into a table.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `table_id` (*type:* `String.t`) - The table into which new rows are being imported.
  *   `upload_type` (*type:* `String.t`) - Upload type. Must be "resumable".
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:delimiter` (*type:* `String.t`) - The delimiter used to separate cell values. This can only consist of a single character. Default is ,.
      *   `:encoding` (*type:* `String.t`) - The encoding of the content. Default is UTF-8. Use auto-detect if you are unsure of the encoding.
      *   `:endLine` (*type:* `integer()`) - The index of the line up to which data will be imported. Default is to import the entire file. If endLine is negative, it is an offset from the end of the file; the imported content will exclude the last endLine lines.
      *   `:isStrict` (*type:* `boolean()`) - Whether the imported CSV must have the same number of values for each row. If false, rows with fewer values will be padded with empty values. Default is true.
      *   `:startLine` (*type:* `integer()`) - The index of the first line from which to start importing, inclusive. Default is 0.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_import_rows_resumable(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          keyword(),
          keyword()
        ) :: {:ok, nil} | {:error, Tesla.Env.t()}
  def fusiontables_table_import_rows_resumable(
        connection,
        table_id,
        upload_type,
        optional_params \\ [],
        opts \\ []
      ) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :delimiter => :query,
      :encoding => :query,
      :endLine => :query,
      :isStrict => :query,
      :startLine => :query
    }

    request =
      Request.new()
      |> Request.method(:post)
      |> Request.url("/resumable/upload/fusiontables/v2/tables/{tableId}/import", %{
        "tableId" => URI.encode(table_id, &URI.char_unreserved?/1)
      })
      |> Request.add_param(:query, :uploadType, upload_type)
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [decode: false])
  end

  @doc """
  Imports more rows into a table.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `table_id` (*type:* `String.t`) - The table into which new rows are being imported.
  *   `upload_type` (*type:* `String.t`) - Upload type. Must be "multipart".
  *   `metadata` (*type:* `String.t`) - string metadata
  *   `data` (*type:* `String.t`) - Path to file
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:delimiter` (*type:* `String.t`) - The delimiter used to separate cell values. This can only consist of a single character. Default is ,.
      *   `:encoding` (*type:* `String.t`) - The encoding of the content. Default is UTF-8. Use auto-detect if you are unsure of the encoding.
      *   `:endLine` (*type:* `integer()`) - The index of the line up to which data will be imported. Default is to import the entire file. If endLine is negative, it is an offset from the end of the file; the imported content will exclude the last endLine lines.
      *   `:isStrict` (*type:* `boolean()`) - Whether the imported CSV must have the same number of values for each row. If false, rows with fewer values will be padded with empty values. Default is true.
      *   `:startLine` (*type:* `integer()`) - The index of the first line from which to start importing, inclusive. Default is 0.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.FusionTables.V2.Model.Import{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_import_rows_simple(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          String.t(),
          String.t(),
          keyword(),
          keyword()
        ) :: {:ok, GoogleApi.FusionTables.V2.Model.Import.t()} | {:error, Tesla.Env.t()}
  def fusiontables_table_import_rows_simple(
        connection,
        table_id,
        upload_type,
        metadata,
        data,
        optional_params \\ [],
        opts \\ []
      ) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :delimiter => :query,
      :encoding => :query,
      :endLine => :query,
      :isStrict => :query,
      :startLine => :query
    }

    request =
      Request.new()
      |> Request.method(:post)
      |> Request.url("/upload/fusiontables/v2/tables/{tableId}/import", %{
        "tableId" => URI.encode(table_id, &URI.char_unreserved?/1)
      })
      |> Request.add_param(:query, :uploadType, upload_type)
      |> Request.add_param(:body, :metadata, metadata)
      |> Request.add_param(:file, :data, data)
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.FusionTables.V2.Model.Import{}])
  end

  @doc """
  Imports a new table.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `name` (*type:* `String.t`) - The name to be assigned to the new table.
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:delimiter` (*type:* `String.t`) - The delimiter used to separate cell values. This can only consist of a single character. Default is ,.
      *   `:encoding` (*type:* `String.t`) - The encoding of the content. Default is UTF-8. Use auto-detect if you are unsure of the encoding.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.FusionTables.V2.Model.Table{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_import_table(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
          {:ok, GoogleApi.FusionTables.V2.Model.Table.t()} | {:error, Tesla.Env.t()}
  def fusiontables_table_import_table(connection, name, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :delimiter => :query,
      :encoding => :query
    }

    request =
      Request.new()
      |> Request.method(:post)
      |> Request.url("/fusiontables/v2/tables/import", %{})
      |> Request.add_param(:query, :name, name)
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.FusionTables.V2.Model.Table{}])
  end

  @doc """
  Imports a new table.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `name` (*type:* `String.t`) - The name to be assigned to the new table.
  *   `upload_type` (*type:* `String.t`) - Upload type. Must be "resumable".
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:delimiter` (*type:* `String.t`) - The delimiter used to separate cell values. This can only consist of a single character. Default is ,.
      *   `:encoding` (*type:* `String.t`) - The encoding of the content. Default is UTF-8. Use auto-detect if you are unsure of the encoding.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_import_table_resumable(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          keyword(),
          keyword()
        ) :: {:ok, nil} | {:error, Tesla.Env.t()}
  def fusiontables_table_import_table_resumable(
        connection,
        name,
        upload_type,
        optional_params \\ [],
        opts \\ []
      ) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :delimiter => :query,
      :encoding => :query
    }

    request =
      Request.new()
      |> Request.method(:post)
      |> Request.url("/resumable/upload/fusiontables/v2/tables/import", %{})
      |> Request.add_param(:query, :name, name)
      |> Request.add_param(:query, :uploadType, upload_type)
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [decode: false])
  end

  @doc """
  Imports a new table.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `name` (*type:* `String.t`) - The name to be assigned to the new table.
  *   `upload_type` (*type:* `String.t`) - Upload type. Must be "multipart".
  *   `metadata` (*type:* `String.t`) - string metadata
  *   `data` (*type:* `String.t`) - Path to file
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:delimiter` (*type:* `String.t`) - The delimiter used to separate cell values. This can only consist of a single character. Default is ,.
      *   `:encoding` (*type:* `String.t`) - The encoding of the content. Default is UTF-8. Use auto-detect if you are unsure of the encoding.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.FusionTables.V2.Model.Table{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_import_table_simple(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          String.t(),
          String.t(),
          keyword(),
          keyword()
        ) :: {:ok, GoogleApi.FusionTables.V2.Model.Table.t()} | {:error, Tesla.Env.t()}
  def fusiontables_table_import_table_simple(
        connection,
        name,
        upload_type,
        metadata,
        data,
        optional_params \\ [],
        opts \\ []
      ) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :delimiter => :query,
      :encoding => :query
    }

    request =
      Request.new()
      |> Request.method(:post)
      |> Request.url("/upload/fusiontables/v2/tables/import", %{})
      |> Request.add_param(:query, :name, name)
      |> Request.add_param(:query, :uploadType, upload_type)
      |> Request.add_param(:body, :metadata, metadata)
      |> Request.add_param(:file, :data, data)
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.FusionTables.V2.Model.Table{}])
  end

  @doc """
  Creates a new table.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:body` (*type:* `GoogleApi.FusionTables.V2.Model.Table.t`) - 
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.FusionTables.V2.Model.Table{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_insert(Tesla.Env.client(), keyword(), keyword()) ::
          {:ok, GoogleApi.FusionTables.V2.Model.Table.t()} | {:error, Tesla.Env.t()}
  def fusiontables_table_insert(connection, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :body => :body
    }

    request =
      Request.new()
      |> Request.method(:post)
      |> Request.url("/fusiontables/v2/tables", %{})
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.FusionTables.V2.Model.Table{}])
  end

  @doc """
  Retrieves a list of tables a user owns.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:maxResults` (*type:* `integer()`) - Maximum number of tables to return. Default is 5.
      *   `:pageToken` (*type:* `String.t`) - Continuation token specifying which result page to return.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.FusionTables.V2.Model.TableList{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_list(Tesla.Env.client(), keyword(), keyword()) ::
          {:ok, GoogleApi.FusionTables.V2.Model.TableList.t()} | {:error, Tesla.Env.t()}
  def fusiontables_table_list(connection, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :maxResults => :query,
      :pageToken => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/fusiontables/v2/tables", %{})
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.FusionTables.V2.Model.TableList{}])
  end

  @doc """
  Updates an existing table. Unless explicitly requested, only the name, description, and attribution will be updated. This method supports patch semantics.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `table_id` (*type:* `String.t`) - ID of the table that is being updated.
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:replaceViewDefinition` (*type:* `boolean()`) - Whether the view definition is also updated. The specified view definition replaces the existing one. Only a view can be updated with a new definition.
      *   `:body` (*type:* `GoogleApi.FusionTables.V2.Model.Table.t`) - 
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.FusionTables.V2.Model.Table{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_patch(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
          {:ok, GoogleApi.FusionTables.V2.Model.Table.t()} | {:error, Tesla.Env.t()}
  def fusiontables_table_patch(connection, table_id, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :replaceViewDefinition => :query,
      :body => :body
    }

    request =
      Request.new()
      |> Request.method(:patch)
      |> Request.url("/fusiontables/v2/tables/{tableId}", %{
        "tableId" => URI.encode(table_id, &URI.char_unreserved?/1)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.FusionTables.V2.Model.Table{}])
  end

  @doc """
  Replaces rows of the table with the rows of the spreadsheet that is first imported from. Current rows remain visible until all replacement rows are ready.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `table_id` (*type:* `String.t`) - Table whose rows will be replaced from the spreadsheet.
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.FusionTables.V2.Model.Task{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_refetch_sheet(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
          {:ok, GoogleApi.FusionTables.V2.Model.Task.t()} | {:error, Tesla.Env.t()}
  def fusiontables_table_refetch_sheet(connection, table_id, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query
    }

    request =
      Request.new()
      |> Request.method(:post)
      |> Request.url("/fusiontables/v2/tables/{tableId}/refetch", %{
        "tableId" => URI.encode(table_id, &URI.char_unreserved?/1)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.FusionTables.V2.Model.Task{}])
  end

  @doc """
  Replaces rows of an existing table. Current rows remain visible until all replacement rows are ready.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `table_id` (*type:* `String.t`) - Table whose rows will be replaced.
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:delimiter` (*type:* `String.t`) - The delimiter used to separate cell values. This can only consist of a single character. Default is ,.
      *   `:encoding` (*type:* `String.t`) - The encoding of the content. Default is UTF-8. Use 'auto-detect' if you are unsure of the encoding.
      *   `:endLine` (*type:* `integer()`) - The index of the line up to which data will be imported. Default is to import the entire file. If endLine is negative, it is an offset from the end of the file; the imported content will exclude the last endLine lines.
      *   `:isStrict` (*type:* `boolean()`) - Whether the imported CSV must have the same number of column values for each row. If true, throws an exception if the CSV does not have the same number of columns. If false, rows with fewer column values will be padded with empty values. Default is true.
      *   `:startLine` (*type:* `integer()`) - The index of the first line from which to start importing, inclusive. Default is 0.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.FusionTables.V2.Model.Task{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_replace_rows(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
          {:ok, GoogleApi.FusionTables.V2.Model.Task.t()} | {:error, Tesla.Env.t()}
  def fusiontables_table_replace_rows(connection, table_id, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :delimiter => :query,
      :encoding => :query,
      :endLine => :query,
      :isStrict => :query,
      :startLine => :query
    }

    request =
      Request.new()
      |> Request.method(:post)
      |> Request.url("/fusiontables/v2/tables/{tableId}/replace", %{
        "tableId" => URI.encode(table_id, &URI.char_unreserved?/1)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.FusionTables.V2.Model.Task{}])
  end

  @doc """
  Replaces rows of an existing table. Current rows remain visible until all replacement rows are ready.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `table_id` (*type:* `String.t`) - Table whose rows will be replaced.
  *   `upload_type` (*type:* `String.t`) - Upload type. Must be "resumable".
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:delimiter` (*type:* `String.t`) - The delimiter used to separate cell values. This can only consist of a single character. Default is ,.
      *   `:encoding` (*type:* `String.t`) - The encoding of the content. Default is UTF-8. Use 'auto-detect' if you are unsure of the encoding.
      *   `:endLine` (*type:* `integer()`) - The index of the line up to which data will be imported. Default is to import the entire file. If endLine is negative, it is an offset from the end of the file; the imported content will exclude the last endLine lines.
      *   `:isStrict` (*type:* `boolean()`) - Whether the imported CSV must have the same number of column values for each row. If true, throws an exception if the CSV does not have the same number of columns. If false, rows with fewer column values will be padded with empty values. Default is true.
      *   `:startLine` (*type:* `integer()`) - The index of the first line from which to start importing, inclusive. Default is 0.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_replace_rows_resumable(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          keyword(),
          keyword()
        ) :: {:ok, nil} | {:error, Tesla.Env.t()}
  def fusiontables_table_replace_rows_resumable(
        connection,
        table_id,
        upload_type,
        optional_params \\ [],
        opts \\ []
      ) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :delimiter => :query,
      :encoding => :query,
      :endLine => :query,
      :isStrict => :query,
      :startLine => :query
    }

    request =
      Request.new()
      |> Request.method(:post)
      |> Request.url("/resumable/upload/fusiontables/v2/tables/{tableId}/replace", %{
        "tableId" => URI.encode(table_id, &URI.char_unreserved?/1)
      })
      |> Request.add_param(:query, :uploadType, upload_type)
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [decode: false])
  end

  @doc """
  Replaces rows of an existing table. Current rows remain visible until all replacement rows are ready.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `table_id` (*type:* `String.t`) - Table whose rows will be replaced.
  *   `upload_type` (*type:* `String.t`) - Upload type. Must be "multipart".
  *   `metadata` (*type:* `String.t`) - string metadata
  *   `data` (*type:* `String.t`) - Path to file
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:delimiter` (*type:* `String.t`) - The delimiter used to separate cell values. This can only consist of a single character. Default is ,.
      *   `:encoding` (*type:* `String.t`) - The encoding of the content. Default is UTF-8. Use 'auto-detect' if you are unsure of the encoding.
      *   `:endLine` (*type:* `integer()`) - The index of the line up to which data will be imported. Default is to import the entire file. If endLine is negative, it is an offset from the end of the file; the imported content will exclude the last endLine lines.
      *   `:isStrict` (*type:* `boolean()`) - Whether the imported CSV must have the same number of column values for each row. If true, throws an exception if the CSV does not have the same number of columns. If false, rows with fewer column values will be padded with empty values. Default is true.
      *   `:startLine` (*type:* `integer()`) - The index of the first line from which to start importing, inclusive. Default is 0.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.FusionTables.V2.Model.Task{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_replace_rows_simple(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          String.t(),
          String.t(),
          keyword(),
          keyword()
        ) :: {:ok, GoogleApi.FusionTables.V2.Model.Task.t()} | {:error, Tesla.Env.t()}
  def fusiontables_table_replace_rows_simple(
        connection,
        table_id,
        upload_type,
        metadata,
        data,
        optional_params \\ [],
        opts \\ []
      ) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :delimiter => :query,
      :encoding => :query,
      :endLine => :query,
      :isStrict => :query,
      :startLine => :query
    }

    request =
      Request.new()
      |> Request.method(:post)
      |> Request.url("/upload/fusiontables/v2/tables/{tableId}/replace", %{
        "tableId" => URI.encode(table_id, &URI.char_unreserved?/1)
      })
      |> Request.add_param(:query, :uploadType, upload_type)
      |> Request.add_param(:body, :metadata, metadata)
      |> Request.add_param(:file, :data, data)
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.FusionTables.V2.Model.Task{}])
  end

  @doc """
  Updates an existing table. Unless explicitly requested, only the name, description, and attribution will be updated.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.FusionTables.V2.Connection.t`) - Connection to server
  *   `table_id` (*type:* `String.t`) - ID of the table that is being updated.
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:alt` (*type:* `String.t`) - Data format for the response.
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
      *   `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead.
      *   `:replaceViewDefinition` (*type:* `boolean()`) - Whether the view definition is also updated. The specified view definition replaces the existing one. Only a view can be updated with a new definition.
      *   `:body` (*type:* `GoogleApi.FusionTables.V2.Model.Table.t`) - 
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.FusionTables.V2.Model.Table{}}` on success
  *   `{:error, info}` on failure
  """
  @spec fusiontables_table_update(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
          {:ok, GoogleApi.FusionTables.V2.Model.Table.t()} | {:error, Tesla.Env.t()}
  def fusiontables_table_update(connection, table_id, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :alt => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :userIp => :query,
      :replaceViewDefinition => :query,
      :body => :body
    }

    request =
      Request.new()
      |> Request.method(:put)
      |> Request.url("/fusiontables/v2/tables/{tableId}", %{
        "tableId" => URI.encode(table_id, &URI.char_unreserved?/1)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.FusionTables.V2.Model.Table{}])
  end
end
